package com.inmobi.commons.thinICE.wifi;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager.WifiLock;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;

public final class WifiScanner
{
  private static Context a = null;
  private static WifiScanListener b = null;
  private static Handler c = null;
  private static boolean d = false;
  private static Runnable e = new b();
  private static boolean f = false;
  private static final BroadcastReceiver g = new a();
  private static final IntentFilter h = new IntentFilter("android.net.wifi.SCAN_RESULTS");
  private static PowerManager.WakeLock i = null;
  private static WifiManager.WifiLock j = null;

  private static void d()
  {
    try
    {
      Handler localHandler = c;
      if (localHandler == null);
      while (true)
      {
        return;
        c.removeCallbacks(e);
        f();
        if (d)
        {
          h();
          j();
        }
        c = null;
        b = null;
        a = null;
        d = false;
      }
    }
    finally
    {
    }
  }

  private static void e()
  {
    if (f)
      return;
    f = true;
    a.registerReceiver(g, h, null, c);
  }

  private static void f()
  {
    if (!f)
      return;
    f = false;
    try
    {
      a.unregisterReceiver(g);
      return;
    }
    catch (IllegalArgumentException localIllegalArgumentException)
    {
    }
  }

  private static void g()
  {
    if (i == null)
    {
      i = ((PowerManager)a.getSystemService("power")).newWakeLock(1, "wifiscanrequester.CpuLock");
      i.setReferenceCounted(false);
    }
    if (!i.isHeld())
      i.acquire();
  }

  private static void h()
  {
    if (i != null)
    {
      if (i.isHeld())
        i.release();
      i = null;
    }
  }

  private static void i()
  {
    if (j == null)
    {
      j = ((WifiManager)a.getSystemService("wifi")).createWifiLock(2, "wifiscanrequester.WiFiScanLock");
      j.setReferenceCounted(false);
    }
    if (!j.isHeld())
      j.acquire();
  }

  private static void j()
  {
    if (j != null)
    {
      if (j.isHeld())
        j.release();
      j = null;
    }
  }

  public static boolean requestScan(Context paramContext, WifiScanListener paramWifiScanListener)
  {
    return requestScan(Looper.myLooper(), paramContext, paramWifiScanListener, 10000L, false);
  }

  public static boolean requestScan(Looper paramLooper, Context paramContext, WifiScanListener paramWifiScanListener, long paramLong, boolean paramBoolean)
  {
    try
    {
      Handler localHandler = c;
      boolean bool1;
      if (localHandler != null)
        bool1 = false;
      while (true)
      {
        return bool1;
        WifiManager localWifiManager = (WifiManager)paramContext.getSystemService("wifi");
        if (!localWifiManager.isWifiEnabled())
        {
          bool1 = false;
        }
        else
        {
          a = paramContext;
          b = paramWifiScanListener;
          d = paramBoolean;
          c = new Handler(paramLooper);
          c.postDelayed(e, paramLong);
          if (d)
          {
            i();
            g();
          }
          e();
          boolean bool2 = localWifiManager.startScan();
          bool1 = bool2;
        }
      }
    }
    finally
    {
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.inmobi.commons.thinICE.wifi.WifiScanner
 * JD-Core Version:    0.6.2
 */